import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';

class ScrollerPage extends StatefulWidget {
  const ScrollerPage({super.key});

  @override
  State<ScrollerPage> createState() => _ScrollerPageState();
}

class _ScrollerPageState extends State<ScrollerPage> {

  var _listViewScrollerController = ScrollController();

  @override
  void initState() {
    _listViewScrollerController.addListener(() {
      print("${_listViewScrollerController.offset}");
    });


  }

  @override
  Widget build(BuildContext context) {

    print("${MediaQuery.of(context).size.width}");
    print("${MediaQuery.of(context).size.height}");
    var width = (MediaQuery.of(context).size.width / 5);


    return Scaffold(
      appBar: AppBar(
        title: Text("ModulePage"),
        centerTitle: true,
        leading: IconButton(
          onPressed: () {
            context.pop();
          },
          icon: Icon(Icons.arrow_back_ios_rounded),
        ),
      ),
      body: SingleChildScrollView(child: Column(children: [
        SizedBox(
          height: 100,
          child: NotificationListener<ScrollNotification>(
            onNotification: (scrollNotification) {

              if(scrollNotification is ScrollStartNotification) {
                print("ScrollStartNotification");
              }

              return false;
            },
            child: ListView.builder( controller: _listViewScrollerController, scrollDirection: Axis.horizontal, shrinkWrap: true, itemCount: 30,  itemBuilder: (context, index) {
                return Container(
                  width: width.toDouble(),
                  height: 100,
                  color: (index % 2 == 0) ? Colors.red : Colors.green,
                );
            }),
          ),
        )
      ])),
    );
  }
}
